
exports.__esModule = true;
exports.default = void 0;

const _utils = require('../utils');

const _field = require('../mixins/field');

const _relation = require('../mixins/relation');

const _createNamespace = (0, _utils.createNamespace)('checkbox-group');
const createComponent = _createNamespace[0];
const bem = _createNamespace[1];

const _default2 = createComponent({
  mixins: [(0, _relation.ParentMixin)('vanCheckbox'), _field.FieldMixin],
  props: {
    max: [Number, String],
    disabled: Boolean,
    direction: String,
    iconSize: [Number, String],
    checkedColor: String,
    value: {
      type: Array,
      default: function _default() {
        return [];
      },
    },
  },
  watch: {
    value: function value(val) {
      this.$emit('change', val);
    },
  },
  methods: {
    // @exposed-api
    toggleAll: function toggleAll(checked) {
      if (checked === false) {
        this.$emit('input', []);
        return;
      }

      let { children } = this;

      if (!checked) {
        children = children.filter((item) => !item.checked);
      }

      const names = children.map((item) => item.name);
      this.$emit('input', names);
    },
  },
  render: function render() {
    const h = arguments[0];
    return h('div', {
      class: bem([this.direction]),
    }, [this.slots()]);
  },
});

exports.default = _default2;
